/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.click.app.model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author orgale
 */
@Entity
@Table(name = "featureProductDescriptions")
@NamedQueries({@NamedQuery(name = "FeatureProductDescription.findAll", query = "SELECT d FROM FeatureProductDescription d"),
    @NamedQuery(name = "FeatureProductDescription.findById", query = "SELECT d FROM FeatureProductDescription d WHERE d.id = :idFeatureProductDescription"),
    @NamedQuery(name = "FeatureProductDescription.findByName", query = "SELECT d FROM FeatureProductDescription d WHERE d.name = :name"),
    @NamedQuery(name = "FeatureProductDescription.findByDescription", query = "SELECT d FROM FeatureProductDescription d WHERE d.description = :description")})
public class FeatureProductDescription extends BaseObject implements Serializable {

    private static final long serialVersionUID = 1L;
    private Long id;
    private String name;
    private String description;
        private String nameEs;
    private String descriptionEs;
    private FeatureProductName featureProductName;

    public FeatureProductDescription() {
    }

    public FeatureProductDescription(Long id) {
        this.id = id;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Basic(optional = false)
    @Column(unique = true, name = "id_featureProductDescription")
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "description")
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FeatureProductDescription)) {
            return false;
        }
        FeatureProductDescription other = (FeatureProductDescription) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.click.app.model.FeatureProductDescription[idFeatureProductDescription=" + id + "]";
    }

    /**
     * @return the featureProductName
     */
    @ManyToOne
    public FeatureProductName getFeatureProductName() {
        return featureProductName;
    }

    /**
     * @param featureProductName the featureProductName to set
     */
    public void setFeatureProductName(FeatureProductName featureProductName) {
        this.featureProductName = featureProductName;
    }

    /**
     * @return the nameEs
     */
    @Column(name = "name_es")
    public String getNameEs() {
        return nameEs;
    }
    /**
     * @param nameEs the nameEs to set
     */
    
    public void setNameEs(String nameEs) {
        this.nameEs = nameEs;
    }

    /**
     * @return the descriptionEs
     */
    @Column(name = "description_es")
    public String getDescriptionEs() {
        return descriptionEs;
    }

    /**
     * @param descriptionEs the descriptionEs to set
     */
    public void setDescriptionEs(String descriptionEs) {
        this.descriptionEs = descriptionEs;
    }
        @Transient
    public String getNameLang() {
        if (getLanguaje() != null && getLanguaje().equals("es") && getNameEs() != null) {
            return getNameEs();
        }
        return getName();
    }
        @Transient
    public String getDescriptionLang() {
        if (getLanguaje() != null && getLanguaje().equals("es") && getDescriptionEs() != null) {
            return getDescriptionEs();
        }
        return getDescription();
    }

}
